import wx

def Brighter(c):
    r, g, b = c.Red()+50, c.Green()+50, c.Blue()+50
    if r>255: r=255
    if g>255: g=255
    if b>255: b=255
    return wx.Color(r, g, b)
    
class rfc3339:

    #TODO: add timezone support

    @staticmethod
    def ToWxDateTime(ts):
        i = ts.find('T')
        if i == -1:
            ts += 'T00:00:00.000Z'
        i = ts.find('Z')
        if i != -1:
            ts = ts[0:i] + '+00:00'
        i = ts.find('+')
        if i == -1: i = ts.find('-')
        
        wxTS = wx.DateTime()
        wxTS.ParseFormat(ts[0:i], '%Y-%m-%dT%H:%M:%S')
        
        return wxTS
    
    @staticmethod
    def FromWxDateTime(wxTS):
        return wxTS.Format('%Y-%m-%dT%H:%M:%S.000Z')

    @staticmethod
    def ToDate(ts):
        i = ts.find('T')
        if i == -1:
            return ts
        else:
            return ts[0:i]    
        
if __name__ == '__main__':
    print rfc3339.ToWxDateTime('2007-03-06T23:41:10.0023Z')
    print rfc3339.FromWxDateTime(wx.DateTime.Now())
    